package Design_patterns.creator_mode.factory.before;

/**
 * @description: 咖啡店
 **/

public class CoffeeStore {
    public Coffee orderCoffee(String type) {
        //声明Coffee 类型变量 根据不同类型创建不同Coffee子类对象
        Coffee coffee = null;
        switch (type) {
            case "american":
                coffee = new AmericanCoffee();
                break;
            case "latte":
                coffee = new LatteCoffee();
                break;
            default:
                throw new RuntimeException("咖啡种类错误");
        }
        //加配料
        coffee.addMilk();
        coffee.addSugar();


        return coffee;
    }
}
